#!/bin/bash

#!/bin/bash
#安装yum源
rpm -Uvh https://repo.mysql.com//yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-10.noarch.rpm
#加载到缓存
yum makecache
#安装mysql5.7
yum -y install mysql-community-server --nogpgcheck


#创建文件夹
mkdir /home/data/logs/mysql -p
cd /home/data && chown -R mysql:mysql logs

#初始化mysqld
mysqld --defaults-file=/etc/my.cnf --user=mysql --datadir=/home/data/mysql --initialize --explicit_defaults_for_timestamp

cp my.cnf /etc/my.cnf

#启动mysqld
systemctl start mysqld